﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System.Collections.Generic;
using FinPlusInterfaces;

namespace FinPlusCompCore
{
    public class FinPlusLink : FinPlusComponent
    {
        [State(Test = true)]
        public override bool IsValid { get; set; }
        [State(Test = true)]
        public override string TestString { get { return Adapter.ToString(); } }
        public override IPods Adapter { get { return _adapter.Adapter; } }

        private readonly IList<IFinPlusComp> _links;
        private readonly IFinPlusComp _adapter;

        //construct
        public FinPlusLink(IFinPlusComp[] links, IFinPlusComp modelLink)
        {
            _adapter = modelLink;
            _links = new List<IFinPlusComp>();
            IsValid = true;
        }

        //common control interface
        public override void Dispose()
        {
            if (_adapter != null)
                _adapter.Dispose();

            foreach (var link in _links)
                if (link != null)
                    link.Dispose();
        }
    }
}
       